﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Buccaneer.Types;
using Buccontrols;

namespace Buccaneer
{
    public class WorkSpace
    {
        private PluginDaddy daddy; 
        private MdiClient ctlClient = new MdiClient();
        public WorkSpace(PluginDaddy daddy)
        {
            this.daddy = daddy;
        }
        
        #region Public Functions

        public void AddPlugin(AvailablePlugin plugin)
        {
            plugin.Instance.Daddy = this.daddy;
            plugin.Instance.MainInterface.Name = plugin.Instance.Name + daddy.MdiChildren.Length.ToString();
            plugin.Instance.Initialize();
            plugin.Instance.MainInterface.Show();
        }

        public void RemovePlugin(string name)
        {
            foreach (PluginForm form in this.daddy.MdiChildren)
            {
                if (form.Name.StartsWith(name))
                {
                    form.Close();
                    break;
                }
            }
        }

        #endregion
    }
}
